#include "Thread.hpp"

using namespace myThread;
#include <vector>

int main(){
    auto l1 = []{
        //int cnt = 10;
        while(1){
            std::cout << "i am a thread" << std::endl;
            sleep(1);
        }
    };

    std::vector<Thread> _threads;

    for(int i = 0; i < 5; ++i){
        Thread thread(l1);
        _threads.push_back(thread);
    }

    for(int i = 0; i < 5; ++i){
        _threads[i].Start();
    }

    int cnt = 10;
    while(cnt--){
        std::cout << "main thread..." << std::endl;
        sleep(1);
    }
    
    for(int i = 0; i < 5; ++i){
        _threads[i].Stop();
        _threads[i].Join();
    }

    
    return 0;
}